package com.mg.yygh.hosp.controller;

import com.mg.yygh.cmn.client.DictFeignClient;
import com.mg.yygh.common.result.Result;
import com.mg.yygh.hosp.service.HospitalService;
import com.mg.yygh.model.hosp.Hospital;
import com.mg.yygh.vo.hosp.HospitalQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author M_Dragon
 * @date 2022/9/1/001 15:32
 */
@Api(tags = "医院信息")
@RestController
@RequestMapping("/admin/hosp/hospital")
//@CrossOrigin
public class HospitalController {

    @Autowired
    private HospitalService hospitalService;

    @ApiOperation("分页带条件查询")
    @GetMapping("/list/{page}/{limit}")
    public Result list(@PathVariable("page") Integer page,
                       @PathVariable("limit") Integer limit,
                       HospitalQueryVo hospitalQueryVo){
        Page<Hospital> hospitals = hospitalService.getPage(page,limit,hospitalQueryVo);
        return Result.ok(hospitals);
    }
    @ApiOperation("更新上线状态")
    @GetMapping("updateStatus/{id}/{status}")
    public Result updateStatus(@PathVariable("id") String id,
                               @PathVariable("status") Integer status){
        hospitalService.updateStatus(id,status);
        return Result.ok();
    }

    @ApiOperation("医院详情信息")
        @GetMapping("showHospDetail/{id}")
    public Result showHospDetail(@PathVariable("id") String id){
        Map<String,Object> map = hospitalService.getHospByid(id);
        return Result.ok(map);
    }
}
